/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kotionokyurievna.gmail.com.bankproject.view;

import java.util.ArrayList;
import java.util.Random;
import kotionokyurievna.gmail.com.bankproject.logic.*;

/**
 *
 * @author Kateryna_Reznik
 */
public class BankMain {
    public static void main ( String args[] ){
        Random rand = new Random();
        Bank bank = new Bank();
        for ( int i = 0; i < 500; i++){
            Account acc = new Account();
            acc.deposit(rand.nextInt(700));
            bank.addAccount( acc );
        }
        System.out.println(bank);
        System.out.println(bank.getBallance());
        
        int accountNumber = bank.getAccountsNumber();
        
        ArrayList<Thread> threadList = new ArrayList<>();
        for ( int i = 0; i < 1000; i++ ){
            threadList.add(new Thread ( new SimpleThread( bank, 
                    rand.nextInt(accountNumber), rand.nextInt(accountNumber), 
                    rand.nextInt(100) + 1)));
        }
        for ( Thread t: threadList ){
            t.start();
        }
        
        for ( Thread t: threadList ){
            try{
                t.join();
            }
            catch ( InterruptedException ex){}
        }
        
        System.out.println(bank);
        System.out.println(bank.getBallance());
    }
}
